Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor interop to use CsWin32/LibraryImport #49

Merged
merged 13 commits into from
Jan 9, 2025
Merged

Conversation

RyanLua
Copy link
Owner

@RyanLua RyanLua commented Jan 7, 2025

Description

Modernizes interop to replace DllImport with LibraryImport or PInvoke with CsWin32 when possible. The goal of this PR is to improve project readability by reducing complexity. This paves the path for being able to add bindable hotkeys in the future.

They are some trade-offs in this PR as it adds CsWin32 as a dependency and CsWin32 still uses DllImport instead of LibraryImport which may pose some AOT issues.

Related Issues

Changes Made

Code Modernization:

Dependency Updates:

Code Cleanup:

Hotkey Handling:

Native Methods:

Checklist

  • Add support for x84
  • Fix SYSLIB1092 diagnostics for incorrect use of LibraryImport
  • Use PInvoke for SendInput in AutoClicker.cs to reduce lines of code
  • I have tested these changes thoroughly.
  • I have reviewed my code for any potential errors or issues.
  • I have followed the code style guidelines for this project.

Additional Notes

@RyanLua RyanLua requested a review from Copilot January 7, 2025 21:49
@RyanLua RyanLua self-assigned this Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • FluentAutoClicker/FluentAutoClicker.csproj: Language not supported
  • FluentAutoClicker/NativeMethods.txt: Language not supported
Comments suppressed due to low confidence (1)

FluentAutoClicker/MainPage.xaml.cs:42

  • The 'wndProc' field is initialized to 'null!' and then assigned later. This could lead to a null reference issue if 'HotKeyProc' is called before 'MainPage_Loaded'. Initialize 'wndProc' properly.
private WNDPROC wndProc = null!;
Copy link

github-actions bot commented Jan 8, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
nuget/Microsoft.Windows.CsWin32 0.3.106 🟢 4
Details
CheckScoreReason
Packaging⚠️ -1packaging workflow not detected
Maintained🟢 40 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 4
Dangerous-Workflow⚠️ -1no workflows found
Security-Policy🟢 10security policy file detected
Token-Permissions⚠️ -1No tokens found
Code-Review⚠️ 0Found 1/11 approved changesets -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Binary-Artifacts🟢 9binaries present in source code
Vulnerabilities🟢 100 existing vulnerabilities detected
License🟢 10license file detected
Fuzzing⚠️ 0project is not fuzzed
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Signed-Releases⚠️ 0Project has not signed or included provenance with any releases.
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • FluentAutoClicker/FluentAutoClicker.csproj

@RyanLua RyanLua marked this pull request as ready for review January 9, 2025 03:10
@RyanLua RyanLua requested a review from Copilot January 9, 2025 03:15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.

Files not reviewed (3)
  • FluentAutoClicker/FluentAutoClicker.csproj: Language not supported
  • FluentAutoClicker/MainPage.xaml: Language not supported
  • FluentAutoClicker/NativeMethods.txt: Language not supported
Comments suppressed due to low confidence (1)

FluentAutoClicker/Program.cs:74

  • The lpName parameter is nullable. Ensure that the nullability is handled correctly, either by adding a null check or handling the nullability explicitly.
string? lpName);
@RyanLua RyanLua merged commit 2f4b123 into main Jan 9, 2025
7 checks passed
@RyanLua RyanLua deleted the refactor-interop branch January 9, 2025 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant